package weekend01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class List04 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("原神");
        list.add("崩坏3rd");
        list.add("崩坏学园2nd");
        System.out.println("list原始数据:"+list);

        Collections.sort(list,new Comparator<String>(){
            public int compare(String o1,String o2){
                return o1.length() - o2.length();
            }
        });
        System.out.println("排序后的数据为:"+list);

        Collections.sort(list,((o1, o2) -> o2.length()-o1.length()));
        System.out.println("倒序后的数据为:"+list);
    }
}
